package com.feihong.txgw.adapter.Holder;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.feihong.txgw.R;
import com.feihong.txgw.ui.activity.HomeActivity;
import com.feihong.txgw.ui.activity.kaika.KaikaHomeActivity;
import com.feihong.txgw.ui.activity.user.LiuLiangChaXunActivity;
import com.feihong.txgw.ui.activity.user.LoginActivity;
import com.feihong.txgw.ui.activity.user.SannerActivity;
import com.feihong.txgw.utils.UserLoginInfo;


import cn.pedant.SweetAlert.SweetAlertDialog;

/**
 * Created by Sabirjan on 2017/6/15.
 * TXGW.
 * 飞宏电子
 */

public class HomeTopBannerViewHolder extends BaseViewHolder {

    private Context mContext;
    public HomeTopBannerViewHolder(Context context, View itemView) {
        super(itemView);
        mContext = context;
//        RefreshToken();
        itemView.findViewById(R.id.lay_scanner).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (UserLoginInfo.isUserLogin()) {
                    Intent intent = new Intent();
                    intent.setClass(mContext, SannerActivity.class);
                    mContext.startActivity(intent);
                }else {
                    HomeActivity homeActivity = (HomeActivity) mContext;
                    homeActivity.showConfirmDialog("未登录", "您还未登录，请先登录！", "登录", "取消", new SweetAlertDialog.OnSweetClickListener() {
                        @Override
                        public void onClick(SweetAlertDialog sweetAlertDialog) {
                            sweetAlertDialog.dismiss();
                            Intent loginIntent = new Intent();
                            loginIntent.setClass(mContext, LoginActivity.class);
                            mContext.startActivity(loginIntent);
                        }
                    });
                }
                }
        });

        itemView.findViewById(R.id.lay_card).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (UserLoginInfo.isUserLogin()) {
                    Intent intent = new Intent();
                    intent.setClass(mContext, KaikaHomeActivity.class);
                    mContext.startActivity(intent);
                } else {

                    HomeActivity homeActivity = (HomeActivity) mContext;
                    homeActivity.showConfirmDialog("未登录", "您还未登录，请先登录！", "登录", "取消", new SweetAlertDialog.OnSweetClickListener() {
                        @Override
                        public void onClick(SweetAlertDialog sweetAlertDialog) {
                            sweetAlertDialog.dismiss();
                            Intent loginIntent = new Intent();
                            loginIntent.setClass(mContext, LoginActivity.class);
                            mContext.startActivity(loginIntent);
                        }
                    });
                }

            }
        });

        itemView.findViewById(R.id.btn_liuliang_chaxun).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (UserLoginInfo.isUserLogin()) {
                    Intent intent = new Intent();
                    intent.setClass(mContext, LiuLiangChaXunActivity.class);
                    mContext.startActivity(intent);
                } else {

                    HomeActivity homeActivity = (HomeActivity) mContext;
                    homeActivity.showConfirmDialog("未登录", "您还未登录，请先登录！", "登录", "取消", new SweetAlertDialog.OnSweetClickListener() {
                        @Override
                        public void onClick(SweetAlertDialog sweetAlertDialog) {
                            sweetAlertDialog.dismiss();
                            Intent loginIntent = new Intent();
                            loginIntent.setClass(mContext, LoginActivity.class);
                            mContext.startActivity(loginIntent);
                        }
                    });
                }
            }
        });

    }

    public void bindData() {

    }
}
